<html>
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body>

<!--
  数据类型   简单类型     复杂类型
     1. number  数值型
     2. undefined  值：undefined
     3. string    字符串   ''   ""
     4. boolean    布尔型   true  false
-->

<script>
    // number  ->  string
    let num = 1
    console.log(num, typeof num)
    /*
    * num = num + ''  //  string类型的优先级较高
    * */
    num = String(num)
    console.log(num, typeof num)

    //  boolean  -> string
    let bool = true
    //bool = bool + ''
    bool = String(bool)
    console.log(bool, typeof bool)  // 'true'


    // string  -> number  NAN   number
    let str_num = '1'
    str_num = str_num * 1
    console.log(str_num, typeof str_num)

    let font_size = '30.5px'
    font_size = parseInt(font_size)
    // font_size =parseFloat(font_size)
    console.log(font_size, typeof font_size)
    str_num = '1'
    str_num = Number(str_num)
    console.log(str_num, typeof str_num)

    let und = Number(undefined)
    console.log(">>>>", und, typeof und)
    // boolean  -> number
    let bl = false
    bl = bl * 1     //  false 0  true  1
    console.log(bl, typeof bl)

    bl = true
    bl = Number(bl)
    console.log(bl, typeof bl)


    // string  - > bool    非空即true
    let str_info = '0'
    str_info = Boolean(str_info)
    console.log(str_info, typeof str_info)
    // number  ->  bool    非零即true    undefined  false
    let num2 = 1
    num2 = Boolean(num2)
    console.log(num2, typeof num2)

</script>
</body>
</html>
